<div id="header">
    <div class="topbar" id="shop_header">
        <?php if(!defined('FRONT_CACHE_STATE') or FRONT_CACHE_STATE != 'true') { ?>
        <div class="layout-2 container">
            <div class="sub-1">
                <?php
                $frontCurrency = $this->frontwebsite()->getFrontCurrency();
                if($frontCurrency and count($frontCurrency)>1) {
                    foreach($frontCurrency as $currency_value) {
                        if($currency_value['currency_state'] == '0') continue;
                        ?>
                        <a class="btn <?php  if ($this->frontwebsite()->getFrontDefaultCurrency() == $currency_value['currency_code']) echo 'btn-primary'; else echo 'btn-gray'; ?> " style="cursor: pointer;" href="<?php echo $this->url('shopfront/default/currency-code', array('action'=>'chanageCurrency','code'=>$currency_value['currency_code'])); ?>"><?php echo $currency_value['currency_name']; ?></a>
                    <?php } } ?>
            </div>
            <div class="sub-2">
                <ul class="nav-x">
                    <?php
                    $shop_top_menu = $this->frontwebsite()->shopFrontMenu(1);
                    if(is_array($shop_top_menu) and !empty($shop_top_menu)) {
                        foreach($shop_top_menu as $top_value) {
                            ?>
                            <li class="item"><a href="<?php echo $top_value['navigation_url']; ?>" <?php if($top_value['navigation_new_window'] == 1) echo 'target="_blank"'; ?>><?php echo $top_value['navigation_title']; ?></a></li>
                            <li class="item split"></li>
                        <?php } } ?>

                    <li class="item down">
                        <a href="<?php echo $this->url('fronthome/default'); ?>"><?php echo $this->translate('会员中心'); ?><i class="fa">&#xf107;</i></a>
                        <div class="dropdown user-box">
                            <ul class="user-center">
                                <li class="link"><a href="<?php echo $this->url('frontorder/default'); ?>"><?php echo $this->translate('我的订单'); ?></a></li>
                                <li class="link"><a href="<?php echo $this->url('frontfavorites/default'); ?>"><?php echo $this->translate('我的收藏'); ?></a></li>
                                <li class="link"><a href="<?php echo $this->url('fronthome/default', array('action'=>'goodsask')); ?>"><?php echo $this->translate('商品咨询'); ?></a></li>
                                <li class="link"><a href="<?php echo $this->url('frontaddress/default'); ?>"><?php echo $this->translate('收货地址'); ?></a></li>
                                <li class="link"><a href="<?php echo $this->url('fronthome/default', array('action'=>'useredit')); ?>"><?php echo $this->translate('个人资料'); ?></a></li>
                                <li class="link"><a href="<?php echo $this->url('fronthome/default', array('action'=>'userpasswd')); ?>"><?php echo $this->translate('密码修改'); ?></a></li>
                            </ul>
                        </div>
                    </li>
                    <?php if($this->frontwebsite()->websiteInfo('shop_QRcode')) { ?>
                    <li class="item split"></li>
                    <li class="item down"><a href=""><?php echo $this->translate('手机商城'); ?></a>
                        <div class="dropdown">
                            <img src="<?php echo  $this->basePath($this->frontwebsite()->createQRcode($this->serverUrl().$this->url('mobile/default'), $this->serverUrl().$this->url('mobile/default'), 'shop')); ?>">
                        </div>
                    </li>
                    <?php } ?>
                    <li class="item split"></li>
                    <li class="item"><a href="<?php echo $this->url('frontorder/default'); ?>"><?php echo $this->translate('我的订单'); ?></a></li>
                    <li class="item split"></li>
                    <?php if($this->frontwebsite()->getUserSession('user_id') != '') {  ?>
                    <li class="item"><a href="<?php echo $this->url('frontuser/default',array('action'=>'loginout')); ?>"><?php echo $this->translate('退出'); ?></a></li>
                    <?php } else { ?>
                    <li class="item"><a class="normal" href="<?php echo $this->url('frontuser/default',array('action'=>'login')); ?>"><?php echo $this->translate('登录'); ?></a>/<a class="normal" href="<?php echo $this->url('frontuser/default',array('action'=>'register')); ?>"><?php echo $this->translate('注册'); ?></a></li>
                    <?php } ?>
                    <?php
                    if($this->frontwebsite()->getUserIni('front_other_login_show') == '1' and $this->frontwebsite()->getUserSession('user_id') == '') {
                        $otherLoginArray = $this->frontwebsite()->getUserOtherLoginIni();
                        if(!empty($otherLoginArray)) {
                            foreach($otherLoginArray as $othKey => $othValue) {
                                if($othValue['login_state'] == 'true') {
                                    $othKey = strtolower($othKey);
                                    ?>
                                    <li class="item"><a href="<?php echo $this->url('frontuser/default',array('action'=>'otherlogin'), array('query'=>array('login_type'=>$othKey))); ?>"><img style="height: 24px;line-height: 24px;padding-top: 5px;" src="<?php echo $this->basePath('public/img/login/'.$othKey.'_login.png'); ?>"></a></li>
                                    <?php
                                }
                            }
                        }
                    }
                    ?>
                    <?php if($this->frontwebsite()->getUserSession('user_id') != '') {  ?>
                        <li class="item"><?php echo $this->translate('你好'); ?>:<?php echo $this->escapeHtml($this->frontwebsite()->getUserSession('user_name')); ?></li><?php } ?>
                </ul>
            </div>
        </div>
        <?php } ?>
    </div>
    <div class="container head-main">
        <div class="sub-1 logo"><a title="" href="<?php echo $this->url('shopfront/default'); ?>"><img src="<?php echo ($this->frontwebsite()->websiteInfo('shop_logo') != '' ? $this->basePath($this->frontwebsite()->websiteInfo('shop_logo')) : $this->basePath('/public/css/dbblack/img/shop_logo.png')); ?>" style="height: 80px;"></a></div>
        <div class="sub-2">
            <form id="search-form" class="search-form" action="<?php echo $this->url('frontgoodslist/default', array('action'=>'goodsSearch')); ?>" method="get">
                <input  class="search-keyword" id="search-keyword" name="keywords" value="<?php echo isset($_GET['keywords']) ? $this->escapehtml($_GET['keywords']) : ''; ?>" placeholder="<?php echo $this->translate('简简单单搜索'); ?>" type="text">
                <button class="btn-search "><?php echo $this->translate('搜索'); ?></button>
                <?php $hot_keywords = @explode('|', $this->frontwebsite()->websiteInfo('shop_hot_keywords'));
                if(is_array($hot_keywords) and !empty($hot_keywords[0])) {
                ?>
                <p id="tags-list">
                    <?php
                    foreach ($hot_keywords as $key_value) {
                    ?>
                    <a href="<?php echo $this->url('frontgoodslist/default', array('action'=>'goodsSearch')); ?>?keywords=<?php echo $this->escapeHtml($key_value); ?>"><?php echo $this->escapeHtml($key_value); ?></a>
                    <?php } ?>
                </p>
                <?php } ?>
            </form>
        </div>
        <div class="sub-3">
            <div class="shopping" id="shopping-cart"><i class="icon-cart-32"></i><?php echo $this->translate('购物车'); ?>
                <div class="dropdown">
                    <ul class="cart-box " id="cart-list">
                        <?php
                        if(!defined('FRONT_CACHE_STATE') or (defined('FRONT_CACHE_STATE') and FRONT_CACHE_STATE != 'true')) {//当关闭缓存时，进行如下处理

                        $cart_array = $this->frontwebsite()->getCartSession();
                        if(!empty($cart_array)) {
                            foreach($cart_array as $cart_key => $cart_value) {
                        ?>
                        <li class="cart-item" id="<?php echo $cart_key; ?>">
                            <div class="pic">
                                <a class="card-pic" href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$cart_value['goods_id'], 'class_id'=>$cart_value['class_id'])); ?>" target="_blank" title="<?php echo $this->escapeHtml($cart_value['goods_name']); ?>"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($cart_value['goods_image'])); ?>" width="50" height="50"></a>
                            </div>
                            <div class="spec">
                                <p>
                                <?php
                                if($cart_value['goods_color_name'] != '' or $cart_value['goods_size_name'] != '') {
                                    if ($cart_value['goods_color_name'] != '') echo  $cart_value['goods_color_name'] . '&nbsp;&nbsp;';
                                    if ($cart_value['goods_size_name'] != '') echo $cart_value['goods_size_name'];
                                }
                                ?>
                                </p>
                            </div>
                            <div class="num"><?php echo $cart_value['buy_num']; ?></div>
                            <div class="price" title="<?php echo $this->frontwebsite()->shopPrice($cart_value['goods_shop_price'])*$cart_value['buy_num']; ?>"><?php echo $this->frontwebsite()->shopPrice($cart_value['goods_shop_price'])*$cart_value['buy_num']; ?></div>
                            <a class="icon-close-16 ie6png" productid="<?php echo $cart_key; ?>"></a>
                        </li>
                        <?php } } else { ?>
                        <li><div><?php echo $this->translate('购物车中还没有商品，赶紧选购吧！'); ?></div></li>
                        <?php } ?>
                    <?php } ?>

                    </ul>
                    <div class="cart-count">
                        <?php if(!empty($cart_array)) { ?>
                        <span><?php echo $this->translate('合计'); ?>：</span><span class="cart-total"><?php echo $this->frontwebsite()->getCartTotal(); ?></span>
                        <?php } ?>
                        <a href="<?php echo $this->url('frontcart/default'); ?>" class="btn btn-main"><?php echo $this->translate('去购物车结算'); ?></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        <?php if(defined('FRONT_CACHE_STATE') and FRONT_CACHE_STATE == 'true') { ?>
        $.get('<?php echo $this->url('shopfront/default',array('action'=>'ajaxheader')); ?>',{}, function(html){
            $("#shop_header").html(html);
        });
        updateCart();
        <?php } ?>
        bindDelEvent();
        function bindDelEvent(){
            $("#shopping-cart .icon-close-16").on("click",function(){
                var btn_close = $(this);
                $.post("<?php echo $this->url('frontcart/default',array('action'=>'delCartGoods')); ?>",{cart_key:btn_close.attr("productid")},function(){
                    btn_close.parent().remove();
                    changeCartInfo();
                    $("#card-wrap").css({top:1-$("#card-wrap").outerHeight()},"fast");
                },"json");
            });
        }
        function updateCart() {
            $.get('<?php echo $this->url('frontcart/default',array('action'=>'ajaxShopCart')); ?>',{}, function(data){
                var card_items = '';
                for(var i in data){
                    var image_path;
                    if(data[i]['yun_type'] == 'yun') {
                        image_path = '';
                    } else {
                        image_path = '<?php echo $this->basePath(); ?>';
                    }
                    card_items += '<div class="cart-item" id="'+i+'"><div class="pic"><img src="'+image_path+data[i]['goods_image']+'" width="50" height="50"></div><div class="spec">'+data[i]['goods_color_name']+data[i]['goods_size_name']+'</div><div class="num">'+data[i]['buy_num']+'</div><div class="price">'+(data[i]['amount'])+'</div><a class="icon-close-16 ie6png" productid="'+i+'"></a></div>';
                }
                $("#cart-list").empty().append(card_items);
                changeCartInfo();
                bindDelEvent();

            },'json');
        }
        function changeCartInfo(){
            $(".cart-product-num").text($(".cart-item").size());
            var total = 0.00;
            $(".cart-item .price").each(function(){
                total += parseFloat($(this).text());
            });
            $(".cart-total").text(total.toFixed(2));
            if($(".cart-item").size()==0){
                $("#cart-list").empty().append('<li><div><?php echo $this->translate('购物车中还没有商品，赶紧选购吧！'); ?></div></li>');
            }
        }
    </script>

    <?php if($this->dbTongJiPage != 'index') { ?>
    <?php echo $this->partial('site/headermenu'); ?>
</div>
<div id="main">
<?php } ?>